# Copyright 2020 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_java//java:defs.bzl", "java_binary")
load("//kotlin/internal/utils:generate_jvm_service.bzl", "generate_jvm_service")
load("//src/main/kotlin:bootstrap.bzl", "kt_bootstrap_library")

# The compiler binary, this is co-located in the kotlin compiler classloader.
kt_bootstrap_library(
    name = "skip-code-gen-lib",
    srcs = glob(["*.kt"]),
    visibility = ["//src:__subpackages__"],
    deps = [
        "//kotlin/compiler:kotlin-compiler",
    ],
)

# services to integrate with the plugin.
generate_jvm_service(
    name = "skip-code-gen-services",
    services = {
        "io.bazel.kotlin.plugin.SkipCodeGen": "org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar",
    },
)

# The plugin binary.
java_binary(
    name = "skip-code-gen",
    visibility = ["//src:__subpackages__"],
    runtime_deps = [
        ":skip-code-gen-lib",
        ":skip-code-gen-services",
    ],
)
